home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Development Kits / HyperCard Related / APDA HyperCard Toolkits / HyperCard CTB Toolkit 1.0b2 / Source Code / CTBConfiguration.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  2.2 KB  |  91 lines  |  [TEXT/MPS ]

  1. (*
  2.     CTBConfiguration([type]) -- Return the current configuration string for the type of tool
  3.         indicated ("connection" (default), "terminal", or "file transfer").
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w CTBConfiguration.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=2754 -sn Main=CTBConfiguration ∂
  9.             CTBConfiguration.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  10.  
  11.     © Copyright 1990 by Apple Computer, Inc.
  12.  
  13.     Initial coding 2/90 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S CTBConfiguration }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. procedure CTBConfiguration(paramPtr: XCmdPtr); forward;
  31.  
  32. procedure EntryPoint(paramPtr: XCmdPtr);
  33.  
  34.     begin
  35.         CTBConfiguration(paramPtr);
  36.     end;
  37.  
  38. procedure CTBConfiguration(paramPtr: XCmdPtr);
  39.  
  40.     {$I CTBUtil.inc}
  41.  
  42.     var i: integer;
  43.         tt: ToolType;
  44.         p, p2: Ptr;
  45.         h: Handle;
  46.         l: longInt;
  47.         err: OSErr;
  48.  
  49.     procedure Fail(errMsg: Str255); { set theResult and quit }
  50.         begin
  51.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  52.             exit(CTBConfiguration);
  53.         end;
  54.  
  55.     begin
  56.         { Check the parameter count. }
  57.         i := paramPtr^.paramCount;
  58.         if i > 1 then Fail('Invalid parameter count');
  59.  
  60.         { Figure out which tool we're getting the configuration for. }
  61.         if i = 0 then tt := connectionTool
  62.         else tt := GetToolTypeParm(1);
  63.  
  64.         { Make sure the Comm Toolbox is here. }
  65.         CTBReady;
  66.  
  67.         { Get the configuration string. }
  68.         p := nil;
  69.         case tt of
  70.             connectionTool: if Globals^^.connHand <> nil then p := CMGetConfig(Globals^^.connHand);
  71.             terminalTool: if Globals^^.termHand <> nil then p := TMGetConfig(Globals^^.termHand);
  72.             fileTransferTool: if Globals^^.FTHand <> nil then p := FTGetConfig(Globals^^.FTHand);
  73.             end;
  74.         { Copy it into a handle and return it. }
  75.         if p <> nil then
  76.             begin
  77.                 p2 := p; l := 1;
  78.                 while p2^ <> 0 do
  79.                     begin
  80.                         p2 := Ptr(ord4(p2)+1);
  81.                         l := l+1;
  82.                     end;
  83.                 err := PtrToHand(p,h,l);
  84.                 DisposPtr(p);
  85.                 FailOSErr(err);
  86.                 paramPtr^.returnValue := h;
  87.             end;
  88.     end;
  89.  
  90. end.
  91.